package com.sudo.designpattern.singleton;

/**
 * 单例模式-懒汉模式（静态内部类）
 * @Author：DayDayUp
 * @Create：2023/4/18 14:35
 */
public class LazyClassSingleton {
    private LazyClassSingleton(){}
    private static class LazySingleton{
        public static LazyClassSingleton instance = new LazyClassSingleton();
    }

    public static LazyClassSingleton getInstance(){
        return LazySingleton.instance;
    }
}

class TestLazyClassSingleton{
    public static void main(String[] args) {
        LazyClassSingleton instance1 = LazyClassSingleton.getInstance();
        LazyClassSingleton instance2 = LazyClassSingleton.getInstance();
        System.out.println(instance1 == instance2);
    }
}
